'use strict';

const ComtrollerService = require('./render');

/**
 * 长按马自达系列报名接口
*/
class MzdController extends ComtrollerService {
  constructor() {
    super(...arguments);

    this.tableName = 'tx_signup';

    this.downloadExcelHeader = [
      { header: '主键ID', key: 'id', width: 10 },
      { header: '名称', key: 'name', width: 15 },
      { header: '手机号', key: 'phone', width: 15 },
      { header: '省份', key: 'province', width: 15 },
      { header: '城市', key: 'city', width: 15 },
      { header: '车系', key: 'series', width: 15 },
      { header: '经销商', key: 'dealer', width: 15 },
      { header: '创建时间', key: 'createtime', width: 25 },
      { header: '第三方回调', key: 'content', width: 50 },
    ];
  }
  /**
   * 新增报名数据
  */
  async create() {
    const { ctx } = this;
    const {
      name,
      phone,
      province_id,
      province,
      city,
      city_id,
      dealer_id,
      series,
      series_id,
      model_id,
      dealer,
      apiid,
      infoplace,
      infosource,
      key,
      activitytag,
    } = ctx.request.body;
    const result = await ctx.service.car.mzdService.send({
      name,
      phone,
      province_id,
      province,
      city,
      city_id,
      dealer_id,
      series,
      series_id,
      model_id,
      dealer,
      apiid,
      infoplace,
      infosource,
      key,
      activitytag,
    });
    ctx.body = result;
  }
}

module.exports = MzdController;
